<template>
  <div class="box">
     <div class="img-box">
      <img src="img/01.gif" alt="">
    </div>
    <div class="top">
        <span :class="{active:arr2==i}" @click="fun(i)" v-for="(v,i) in arr" :key="i">{{v}}</span>
    </div>
    <div class="goods" v-for="(v,i) in arr1" :key="i">
        <img :src="v.picture" alt="">
        <div class="content">
            <h3>{{v.name}}</h3>
            <p>{{v.unit}}</p>
            <div class="price">
                <p><span><i>￥</i>{{v.min_price}}</span></p>
                <div>
                    <div class="big-box" @click="fun1(v)">马上抢</div>
                    <p>已售{{v.month_saled}}份</p>
                </div>
            </div>
        </div>
    </div>
  </div>
</template>

<script>
import {tuan_list,tuan_list1} from "../../utils/apis.js"
export default {
    data(){
        return{
            arr:["正在抢购","上新预告"],
            arr1:[],
            arr2:0,
           
        }
    },
    mounted(){
       tuan_list().then((res)=>{
         console.log(res.data.list)
         this.arr1=res.data.list
       })
    },
    methods:{
        fun(i){
            this.arr2=i
            if(i==0){
              tuan_list().then((res)=>{
            //    console.log(res.data.list)
               this.arr1=res.data.list
              })
            }else if(i==1){
               tuan_list1({status:0}).then((res)=>{
            //    console.log(res.data.list)
               this.arr1=res.data.list
            })
              }
            }
        },
        fun1(v){
            console.log(v.text)
            v.text="已抢"
        }
    }

</script>

<style lang="scss" scoped>
.box{
    .img-box{
  width: 100%;
  >img{
    width: 100%;
    vertical-align: middle;
  }
}
.top{
    display: flex;
    background-color: #e94827;
    color: #fff;
    padding: 0 0 10px 0;
    .active{
        font-weight: 600;
    }
    >span{
        font-size: 18px;
        margin-left: 14px;
    }
}
.goods{
    display: flex;
    padding: 12px 12px 0 12px;
    >img{
        width: 120px;
        height: 120px;
    }
    .content{
        flex: 1;
        margin-left: 10px;
        >p{
            font-size: 12px;
            color: rgb(135, 129, 129);
        }
        h3{
            font-size: 18px;
            margin: 12px 0;
        }
        .price{
            display: flex;
            justify-content: space-between;
            align-items: center;
            >p {
                display: flex;
                span{
                color: #f00;
                font-size: 20px;
                i{
                    font-size: 14px;
                }
            }
            }
            .big-box{
                padding: 8px 14px;
                border-radius: 20px;
                background-color: #eb5127;
                color: #fff;
            }
            >div{
                text-align: center;
                 p{
                color: #f00;
                font-size: 12px;
                }
            }

        }
    }
}
}

</style>